import { CommonResult } from '../types/global';
import { OperationStrategy } from '../types/marketing';
import { http } from "../utils/http"



export const getCategories = () => {
	return http<string[]>({
		url: '/fanqie/shopManagerStrategy/getCategories',
		method: 'GET'
	})
}


/**
 * 获取指定分类的运营策略列表
 */
export const getStrategiesByCategory = (category : string) => {
	return http<OperationStrategy[]>({
		url: '/fanqie/shopManagerStrategy/getStrategiesByCategory',
		method: 'GET',
		data: { category }
	})
}


/**
 * 获取指定分类的运营策略列表
 */
export const getStrategiesById = (id : number) => {
	return http<OperationStrategy>({
		url: '/fanqie/shopManagerStrategy/getStrategiesById',
		method: 'GET',
		data: { id }
	})
}

//新增运营策略
export const addStrategy = (strategy : OperationStrategy) => {
	return http<CommonResult>({
		url: '/fanqie/shopManagerStrategy/addStrategy',
		method: 'POST',
		data: strategy
	})
}

//修改运营策略
export const updateStrategy = (strategy : OperationStrategy) => {
	return http<CommonResult>({
		url: '/fanqie/shopManagerStrategy/updateStrategy',
		method: 'POST',
		data: strategy
	})
}
//根据id删除运营策略
export const deleteStrategy = (id : number) => {
	return http<CommonResult>({
		url: '/fanqie/shopManagerStrategy/deleteStrategy?id=' + id,
		method: 'DELETE'
	})
}